package com.cnki.caselib.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.cnki.caselib.dao.CategoryDao;
import com.cnki.caselib.domain.Category;
import com.cnki.caselib.domain.User;
import com.cnki.caselib.util.ResponseUtil;

@Controller
public class MenuController {
	@Autowired
	@Qualifier("categoryDao")
	private CategoryDao categoryDao = null;

	@Autowired
	@Qualifier("responseUtil")
	private ResponseUtil resUtil = null;

	private Log logger = LogFactory.getLog(MenuController.class);

	@RequestMapping("/menu.htm")
	public String showMenu(HttpServletResponse response, ModelMap model, HttpServletRequest request)
			throws IOException, Exception {
		User user = (User) request.getSession().getAttribute("currUser");
		int login = 0;
		if (user != null){
			login = 1;
			model.put("user", user);
		}
			
		List<Category> lists = categoryDao.getAllCategory();
		model.put("cateList", lists);
		model.put("login", login);
		return "/menu.htm";
	}


}
